package com.zmn.oms.dubbo.impl.conf.workturn.biztype;

import com.zmn.common.dto2.ResponseDTO;
import com.zmn.oms.dubbo.interfaces.conf.workturn.biztype.PlatBizTypeListRemoteService;
import com.zmn.oms.dubbo.utils.DubboConsts;
import com.zmn.oms.services.interfaces.conf.workturn.biztype.PlatBizTypeService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 类描述:
 *
 * @author: HuangChao
 * @since: 2022/08/22 15:13
 */
@Slf4j
@DubboService(loadbalance = "roundrobin", timeout = 5000, retries = 2, version = DubboConsts.INTERFACE_VERSION)
public class PlatBizTypeListRemoteServiceImpl implements PlatBizTypeListRemoteService {

    @Autowired
    private PlatBizTypeService platBizTypeService;

    @Override
    public ResponseDTO<List<Integer>> listBizTypeByPlat(@Validated @NotNull(message = "plat不能为空") Integer plat) {
        try {
            List<Integer> list = platBizTypeService.listBizTypeByPlat(plat);
            return ResponseDTO.success(list);
        } catch (Exception e) {
            log.error("获取配置失败：{}", e);
            return ResponseDTO.fail(e.getMessage());
        }
    }
}
